import Router from 'koa-router';
import swaggerJSDoc from 'swagger-jsdoc';
import {koaSwagger} from "koa2-swagger-ui";
import swaggerUI from 'koa2-swagger-ui'

const options = {
  definition: {
    openapi: '3.0.0',
    info: {
      title: '我是标题',
      version: '1.0.0',
      description: '我是描述',
    },
    servers: [
      {url: '/api', description: 'API server'},
    ],
  },
  apis: ['./src/**/*.js'],
};


export default (app) => {
  const swaggerSpec = swaggerJSDoc(options);

  const router = new Router();

  router.get('/swagger', koaSwagger({routePrefix: false, swaggerOptions: {spec: swaggerSpec}}));
  app.use(router.routes()).use(router.allowedMethods());
}

